/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package be.khk.lesson;

import java.util.Collection;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.OneToMany;
import javax.persistence.Persistence;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 *
 * @author Yorre
 */
@ManagedBean
@RequestScoped
public class BetaalmethodeController {

    private Integer id;
    private String betaalMethode;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getBetaalMethode() {
        return betaalMethode;
    }

    public void setBetaalMethode(String betaalMethode) {
        this.betaalMethode = betaalMethode;
    }

    /**
     * Creates a new instance of BetaalmethodeController
     */
    public BetaalmethodeController() {
    }
    
    public List<Betaalmethode> getBetaalmethodes(){
        
        EntityManagerFactory emf = null;
        try {
            emf = Persistence.createEntityManagerFactory("Awesome_RD_TravelshopPU");
//let op: gebruik hier de juiste naam van de persistence unit 
//(zoek op in persistence.xml)

           EntityManager em2 = emf.createEntityManager();
            List<Betaalmethode> betaalmethodes = em2.createNamedQuery("Betaalmethode.findAll").getResultList();
            return betaalmethodes;
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        } finally {
            emf.close();
        }



    }
}
